<?php
   class Model_albums extends CI_Model{
		protected $_table = "tbl_albums";
		protected $_destina = "tbl_destination";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function listdestina(){
			return $this->db->get($this->_destina)->result_array();
		}
		public function getdata($id){
			$this->db->where("id",$id);
			return $this->db->get($this->_table)->row_array();
		}
		public function listalllimit($off,$start){
			$this->db->order_by("id","DESC");
			$this->db->limit($off,$start);
			return $this->db->get($this->_table)->result_array();
		}
		public function listall($off,$start){
			$this->db->join("tbl_destination","tbl_destination.destina_id = tbl_albums.destina_id");
			$this->db->limit($off,$start);
			return $this->db->get($this->_table)->result_array();
		}
		public function count_all(){
			$this->db->join("tbl_destination","tbl_destination.destina_id = tbl_albums.destina_id");
        	return $this->db->count_all_results($this->_table);
    	}
		public function getalbums($destina_id){
			$this->db->where("destina_id",$destina_id);
//			$this->db->order_by("priority","asc");
			return $this->db->get($this->_table)->result_array();
		}
		public function getdatabycategoryid($categoryid){
			$this->db->where("categoryid",$categoryid);
//			$this->db->order_by("priority","asc");
			return $this->db->get($this->_table)->result_array();
		}
		public function related($destina_id,$id){
			$this->db->where("destina_id",$destina_id);
			$this->db->where("id !=",$id);
			return $this->db->get($this->_table)->result_array();
		}
		public function add($data){
        	$this->db->insert($this->_table,$data);
		}
		public function del($id){
			$this->db->where("id",$id);
			$this->db->delete($this->_table);
		}
		public function update($data,$id){
			$this->db->where("id",$id);
			$this->db->update($this->_table,$data);
		}
	}